package lab03.test01;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Test01 {
    public static void main(String[] args) {
        //定义路径
        String path = "D:\\Test.txt";
        //读取文件（一行一行地读）
        //BufferedReader是缓冲字符输入流。
        BufferedReader bufferedReader= null;
        try {
            bufferedReader = new BufferedReader(new FileReader(path));
            String line = "";
            while ((line = bufferedReader.readLine()) != null){//readLine读一行
                System.out.println(line);
            }
            int data;
            while ((data = bufferedReader.read()) != -1){
                System.out.print(data + "\t");//写
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                bufferedReader.close();//关闭文件夹
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
